{extend name="../../admin/view/full"}

{block name="content"}
<div class="iframe-pagination">
    {include file='shop/goods/select_search'}
    <table class="layui-table margin-top-10" lay-skin="line">
        {notempty name='list'}
        <thead>
        <tr>
            <th>商品信息</th>
            <th>商品状态</th>
            <th></th>
        </tr>
        </thead>
        {/notempty}
        <tbody>
        {foreach $list as $key=>$vo}
        <tr>
            <td class='nowrap'>
                {notempty name='vo.cover'}
                <div class="headimg" data-lazy-src="{$vo.cover}" data-tips-image></div>
                {/notempty}
                <div class="inline-block">
                    商品编号：{$vo.code|default='--'}<br>
                    商品名称：{$vo.name|default='--'}<br>
                </div>
            </td>
            <td class='nowrap sub-span-blue'>
                销售状态：{if $vo.status eq 0}<b class="color-red">已下架</b>{else}<b class="color-green">销售中</b>{/if}<br>
                剩余库存 <span>{$vo.stock_total-$vo.stock_sales}</span> 件 ( 已销售 <span>{$vo.stock_sales}</span> 件 )<br>
            </td>
            <td class='text-right'><a class="layui-btn layui-btn-sm layui-btn-normal" data-item="{$vo.code}">选择商品</a></td>
        </tr>
        {/foreach}
        </tbody>
    </table>
    {empty name='list'}<span class="notdata">没有记录哦</span>{else}{$pagehtml|raw|default=''}{/empty}
</div>
{/block}

{block name='script'}
<script>
    $('[data-item]').on('click', function () {
        top.setItemValue(this.getAttribute('data-item') || '');
        parent.layer.close(parent.layer.getFrameIndex(window.name));
    });
</script>
{/block}
